﻿using Max.PH5_2011A.Domain;
using Max.PH5_2011A.DTO;
using Max.PH5_2011A.IService;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Max.PH5_2011A.API.Controllers
{
    /// <summary>
    /// 
    /// </summary>
    [Route("address")]
    [ApiController]
    public class MemberAddressController : BaseController<MemberAddressModel>
    {
        IMemberAddressService _service;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="serice"></param>
        public MemberAddressController(IMemberAddressService serice) : base(serice)
        {
            _service = serice;
        }

        /// <summary>
        /// 添加地址
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        [HttpPost]
        public override IActionResult Insert(MemberAddressModel t)
        {
            ResponseResultDto<dynamic> dto = new();
            int result = _service.InsertAddress(t);
            dto.Data = result;
            return Ok(dto);
        }

        /// <summary>
        /// 添加地址
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        [HttpGet("bymemberid")]
        public  IActionResult Query(string memberId)
        {
            ResponseResultDto<dynamic> dto = new();


            var result = _service.Query().Where(x=>memberId.Equals(x.MemberId.ToString()));
            dto.Data = result;
            return Ok(dto);
        }

    }
}
